<template>
  <div class="recommend">
    <div class="top">
      <ul>
        <li><router-link to="/play/listen">听听</router-link></li>
        <li><router-link to="/play/recommend">推荐</router-link></li>
        <li><router-link to="/play/classify">分类</router-link></li>
      </ul>
    </div>
    <van-nav-bar>
      <template #left>
        <van-icon name="apps-o" size="18" @click="showpo" color="#333" />
      </template>
      <template #right>
        <van-icon name="ellipsis" size="18" color="#333" />
      </template>
    </van-nav-bar>

    <van-search
      v-model="value"
      disabled=""
      shape="round"
      background="#fff"
      placeholder="请输入搜索关键词"
    />
    <div class="recommended_ym">
      <div class="recommended_t">
        <h1>猜你喜欢</h1>
        <p @click="change()">换一批</p>
        <span>兴趣定制></span>
      </div>
      <ul class="recommended_ul">
        <li v-for="(item, index) in list" :key="index">
          <img :src="item.picUrl" alt="" />
          <p>
            <span>{{ item.category }}</span> <br />
            <span class="class_span">{{ item.copywriter }}</span>
          </p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { reqRadioApi } from "../../../api/radio";
export default {
  name: "recommend",
  data() {
    return {
      value: "",
      list: [],
    };
  },
  props: [],
  components: {},
  computed: {},
  watch: {},
  created() {
    this.reqRadiolist();
  },
  mounted() {},
  methods: {
    //  全局事件总线
    showpo() {
      this.$bus.$emit("showPopup");
    },
    async reqRadiolist(num) {
      let params = { limit: 30, offset: num };
      const result = await reqRadioApi(params);
      console.log(result);
      if (result.code == 200) {
        this.list = result.djRadios;
        console.log(this.list);
      }
    },
    change() {
      const num = parseInt(Math.random() * 29);
      this.reqRadiolist(num);
    },
    baidu() {
      this.$router.push("home");
    },
  },
};
</script>

<style scoped>
.recommended_ym {
  width: 100%;
  height: auto;
}
.recommended_t {
  width: 100%;
  height: 60px;
  line-height: 60px;
}
.recommended_t h1 {
  display: inline-block;
  font-size: 24px;
  font-weight: bold;
  margin-left: 10px;
}
.recommended_t p {
  display: inline-block;
  font-size: 20px;
  font-weight: 500;
  margin-left: 10px;
}
.recommended_t span {
  font-size: 16px;
  font-weight: 300;
  float: right;
}
.recommended_ul {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  padding-bottom: 55px;
}
.recommended_ul li {
  display: inline-block;
  width: 30%;
  padding: 4px 2px;
}
.recommended_ul li img {
  width: 100%;
  border-radius: 20px;
}
.recommended_ul li p span:nth-of-type(1) {
  font-size: 14px;
  color: #aaa;
}
.recommended_ul li p span:nth-of-type(2) {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  display: block;
}
.top {
  width: 80%;
  height: 50px;
  line-height: 50px;
  position: absolute;
  top: -4px;
  left: 47px;
  z-index: 999;
}
.top ul {
  width: 100%;
  height: 50px;
  line-height: 50px;
  text-align: center;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.top ul li {
  margin: 0 10px;
}
.top ul li:nth-of-type(2) a {
  color: black;
  font-size: 17px;
  font-weight: bold;
}
li:nth-of-type(2) a {
  position: relative;
}
li:nth-of-type(2) a:before {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 36px;
  height: 5px;
  border-radius: 5px;
  background: red;
}
</style>
